function[] = kNNValidation()
% Validates the kNN-algorithm with the wine-dataset.

    disp('KNN-CLASSIFICATION');
    wines = loadWines('../Wine/wine.data');
    F = dir('FeatureCombinationDefs/*.txt');
    for featureFilter = 1 : size(F, 1)
        featureFilteredWines = filterFeatures(wines, ['FeatureCombinationDefs/' F(featureFilter).name]);
        disp(['Feature combination according to file [' F(featureFilter).name ']']);
        D = dir('TrainingSetDefs/*.txt');
        for split = 1 : size(D, 1)
            [trainingSet, testSet] = splitIntoTrainingAndTest(featureFilteredWines, ['TrainingSetDefs/' D(split).name]);
            disp(['  Separation into training and test dataset according to file [' D(split).name ']']);
            for k = [1 2 3 5 10]
                correct = 0;
                for i = 1 : size(testSet, 2)
                    result = kNNClassification(testSet(2:size(testSet,1), i), k, trainingSet);
                    if result == testSet(1, i)
                        correct = correct + 1;
                    end
                end
                disp(['    k = ' num2str(k) ': ' num2str(correct) '/' num2str(size(testSet, 2))]);
            end
        end
    end
end
